package com.berry.MedCheck;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;

/**
 * Created by Airay.Rong on 13-12-25.
 */
public class GuildActivity extends BaseActivity {
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.guild_activity);
		Button mbtn = (Button) findViewById(R.id.guild_start);
		mbtn.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				writePreference_ShowGuild();
				finish();
				startActivity(new Intent().setClass(GuildActivity.this,ChooseUserActivity.class));
			}
		});
	}
	private void writePreference_ShowGuild() {
		SharedPreferences sp = getSharedPreferences(Utils.PREFERENCE_NAME, 0);
		SharedPreferences.Editor me = sp.edit();
		me.putBoolean(Utils.PRE_KEY_CURRENT_GUILD, true);
		me.commit();
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			writePreference_ShowGuild();
			startActivity(new Intent().setClass(GuildActivity.this, WelcomeActivity.class));
			finish();
			return false;
		}
		return super.onKeyDown(keyCode, event);
	}
}